import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import electron from 'vite-plugin-electron';
import { resolve } from 'path';

export default defineConfig({
  plugins: [
    vue(),
    electron({
      entry: 'main.js',
      vite: {
        build: {
          outDir: 'dist',
          rollupOptions: {
            external: ['electron']
          }
        }
      }
    }),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
    },
  },
  base: process.env.ELECTRON_RENDERER_URL || './',
  build: {
    outDir: 'dist',
    assetsDir: '.',
    emptyOutDir: true,
    rollupOptions: {
      external: ['electron'],
      input: {
        main: resolve(__dirname, 'index.html')
      }
    }
  },
  server: {
    port: 5173,
    strictPort: true,
    hmr: {
      protocol: 'ws'
    },
    headers: {
      'Content-Security-Policy': [
        "default-src 'self' 'unsafe-inline' 'unsafe-eval' data: blob:;",
        "script-src 'self' 'unsafe-inline' 'unsafe-eval';",
        "style-src 'self' 'unsafe-inline';",
        "img-src 'self' data: blob: https:;",
        "font-src 'self' data:;"
      ].join(' ')
    }
  },
  optimizeDeps: {
    include: ['md-editor-v3']
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "md-editor-v3/lib/style.css";`
      }
    }
  }
}); 